package com.renshengjiwu.web.frontend;

import com.renshengjiwu.utils.BeetlSharedVarsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/")
public class HomeController {
    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
    @GetMapping({ "/{page}" })
    public ModelAndView dashboard(HttpServletRequest request, @PathVariable(name = "page",required = false) String page) {
        // Subject currentUser = SecurityUtils.getSubject();
        // logger.info("dashboard, getCurrentUser()=" + currentUser);
        logger.error("----------page = "+page);
        ModelAndView view = new ModelAndView("/Blog/"+page);
        return view;
    }

    @GetMapping({ "/", "" })
    public ModelAndView home(HttpServletRequest request) {
        BeetlSharedVarsUtil.setupOnlineSharedVars(request);
        ModelAndView view = new ModelAndView("/Blog/index.html");
        return view;
    }
}
